/*
package com.tedu.weibotest.conteoller;

import com.tedu.weibotest.mapper.WeiboMapper;
import com.tedu.weibotest.pojo.dto.WeiboDTO;
import com.tedu.weibotest.pojo.entity.User;
import com.tedu.weibotest.pojo.entity.Weibo;
import com.tedu.weibotest.pojo.vo.WeiboDetailVO;
import com.tedu.weibotest.pojo.vo.WeiboIndexVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpSession;
import java.util.Date;
import java.util.List;

@Api(tags = "微博模块")
@RestController
@RequestMapping("/v1/weibo")
@Slf4j
public class WeiboController {
    @Autowired
    private WeiboMapper weiboMapper;
    @ApiOperation("发表微博功能")
    @PostMapping("/insert")
    public int insert(@RequestBody WeiboDTO weiboDTO , HttpSession session){
        log.info("WeiboController.insert(),发表微博");
        log.trace("开始执行insert方法");

        User user=(User) session.getAttribute("user");
        log.trace("通过session获取用户登录信息");
        log.debug("user:"+user);

        if (user==null){
            log.trace("user为null,未登录");
            return 2;

        }else {
            log.trace("user不为null，继续后续");
            Weibo weibo=new Weibo();
            BeanUtils.copyProperties(weiboDTO,weibo);
            weibo.setCreated(new Date());
            weibo.setUserId(user.getId());
            log.debug("weibo:"+weibo);
            weiboMapper.insert(weibo);
            log.trace("插入微博完毕");
            return 1;
        }

    }
    @ApiOperation("获取首页微博列表")
    @GetMapping("/selectIndex")
    public List<WeiboIndexVO>selectIndexWeibo(){
        return weiboMapper.selectWeibo();
    }

    @ApiOperation("获取微博详情")
    @GetMapping("/selectById")
    public WeiboDetailVO selectById( Integer id){
        return weiboMapper.selectById(id);
    }
}


*/
